﻿@namespace YwhWeb.Pages.Daily

<div class="buildingView" style="text-align: right;">
    <Divider></Divider>
    <div class="left" style="min-width: 310px;">
         <PageContainer>
        <Content>   
            <Button @onclick="_=>NewDrawer()">添加记录</Button> 
            
            </Content>

        
            <ChildContent>
            <Table @ref="table"
                   TItem="YwhLib.Building"
                   DataSource="@buildingRsp.Items"
                   Total="_total"
                   @bind-PageIndex="_pageIndex"
                   @bind-PageSize="_pageSize"
                   @bind-SelectedRows="selectedRows"
                   OnChange="OnChange">
                <Selection Key="@(context.BuildingNo.ToString())" />
                <AntDesign.Column Title="期号" @bind-Field="@context.PhaseNo" Sortable />
                <AntDesign.Column Title="楼号" @bind-Field="@context.BuildingNo" Sortable/>
                <AntDesign.Column Title="单元数量" @bind-Field="@context.UnitNum" Sortable/>
                <ActionColumn Title="操作">
        <Space>
            <SpaceItem>
                <Button Danger OnClick=UpdateBuilding>编辑</Button>
                <Button Danger OnClick=DeleteBuilding>删除</Button>
                </SpaceItem>
        </Space>
    </ActionColumn>
            </Table>
            </ChildContent>
    </PageContainer>
    </div>
</div>

<Drawer Visible="this.drawerVisible" Width="400" OnClose="a=>{this.drawerVisible=false;}">
    <Form Model=@editBuilding>
    <ChildContent>
    <Title Level="4">添加楼栋</Title>
    <div>
    <p ></p>
 </div>

 <Text>期号:</Text>
    <div>
    <Select DataSource="@phaseOptions" 
        @bind-Value="@editBuilding.PhaseNo"
        LabelName="@nameof(Phase.PhaseNoS)" 
        ValueName="@nameof(Phase.PhaseNo)" 
        DefaultValue=0
        Placeholder="请选择期数"
        OnSelectedItemChanged="OnSelectedItemChangedHandler"
        SortByLabel="@SortDirection.Ascending"
        AllowClear
        Style="width: calc(100% - 68px);">
</Select>

    <p></p>
</div>

<Text>楼号:</Text>
    <div>
    <Input Placeholder="请输入楼号" @bind-Value="@editBuilding.BuildingNo"  />
    <p></p>
</div>

<Text>单元数量:</Text>
    <div>
    <Input Placeholder="请输入单元数量" @bind-Value="@editBuilding.UnitNum"  />
    <p></p>
</div>

<div style="text-align: right;">
    <Button Type="@ButtonType.Primary" OnClick=SaveBuilding>保存</Button>
</div>
 </ChildContent>
</Form>
</Drawer>